package com.rc.saas.mini.service.enterprise;

import com.rc.saas.mini.mapper.enterprise.EnterpriseSubmemberShareMapper;
import com.rc.saas.mini.model.enterprise.EnterpriseSubmemberShare;
import com.rc.saas.mini.model.enterprise.EnterpriseSubmemberShareExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @author wangzhengwei
 * @create 2021/12/21
 */
@Service
public class EnterpriseSubmemberShareServiceImpl implements EnterpriseSubmemberShareService {

    @Autowired
    private EnterpriseSubmemberShareMapper enterpriseSubmemberShareMapper;

    @Override
    public EnterpriseSubmemberShareMapper getMapper() {
        return enterpriseSubmemberShareMapper;
    }

    @Override
    public EnterpriseSubmemberShare selectSubmeberByMemberId(Long memberId) {
        EnterpriseSubmemberShareExample example = new EnterpriseSubmemberShareExample();
        example.createCriteria().andMemberIdEqualTo(memberId).andStatusEqualTo("1").andEndTimeGreaterThan(new Date()).andBeginTimeLessThan(new Date());
        return enterpriseSubmemberShareMapper.selectByExample(example).stream().findFirst().orElseGet(() -> null);
    }


}
